package com.manli.api.service;

import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.List;
import com.manli.api.pojo.Result;
import com.manli.api.util.ResultUtil;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import com.manli.api.dao.GeneratorTestDao;
import com.manli.api.dto.GeneratorTest;


@Service("generatorTestService")
public class GeneratorTestService {
    @Autowired
    GeneratorTestDao generatorTestDao;

    
    public Result queryPage(Map<String, Object> params) {
        PageQuery<GeneratorTest> page = generatorTestDao.createQuery()
                .page(Long.parseLong(params.get("page").toString()),Long.parseLong(params.get("limit").toString()));
        return ResultUtil.success(page.getList(),page.getTotalRow());
    }

    
    public Result queryAll() {
        List<GeneratorTest> list = generatorTestDao.all();
        return ResultUtil.success(list);
    }

    
    public Result getById(Integer id) {
        GeneratorTest generatorTest = generatorTestDao.single(id);
        return ResultUtil.success(generatorTest);
    }

    
    public Result save(GeneratorTest generatorTest) {
        generatorTestDao.insert(generatorTest);
        return ResultUtil.success();
    }

    
    public Result updateById(GeneratorTest generatorTest) {
        generatorTestDao.updateTemplateById(generatorTest);
        return ResultUtil.success();
    }

    
    public Result removeById(Integer id) {
        generatorTestDao.deleteById(id);
        return ResultUtil.success();
    }

    
    public Result removeByIds(List<Integer> ids) {
        for (Integer id:ids) {
            generatorTestDao.deleteById(id);
        }
        return ResultUtil.success();
    }



}
